<template>
  <view class="page">
    <custom-navbar title="页面标题" :showBack="true" titleColor="#333333">
      <!-- 自定义右侧内容 -->
      <template #right>
        <view>右侧内容</view>
      </template>
    </custom-navbar>
    <view class="logo-box df-ac fd-c">
      <text class="color-theme">text1111</text>
      <text class="scss-test">theme</text>
      <image class="logo" src="/static/logo.png"></image>
    </view>
    <up-button type="primary" shape="circle" text="按钮形状"></up-button>
    <up-calendar :show="show" @close="show = false"></up-calendar>
    <up-button @click="show = true">打开</up-button>
    <up-button @click="handleLogin">登录</up-button>
  </view>
</template>

<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
import { storeToRefs } from "pinia";
import { getTest, postTest, userInfoApi } from "@/common/request/api/index.js";
import { useUserStore } from "@/stores/user";
const show = ref();

// 请求
function getTestData() {
  // show.value = 1;
  // console.log(show.value);
  getTest().then((res) => {
    // console.log(res);
  });
}

function postTestData() {
  const postData = {
    pageNum: 1,
    pageSize: 10,
    countryCode: "CN",
    cityCode: "CN_C_76142",
  };
  postTest(postData).then((res) => {
    // console.log(res);
  });
}

onLoad(() => {
  getTestData();
  postTestData();
});
// ---------------------------------------------------

// pinia
const user = useUserStore();
// 如果要用解构  要收用storeToRefs才能变为响应式
// const { userInfo } = storeToRefs(user);
async function handleLogin() {
  let userInfo = await userInfoApi();
  user.setUserInfo(userInfo);
}
// --------------------------------------------------------
</script>

<style lang="scss" scoped>
.page {
  padding-top: calc(var(--status-bar-height) + 44px);
}
.scss-test {
  font-size: 20rpx;
  color: $theme;
}
</style>
